﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace NpCrm.Domain
{
    public class Contact : NpCrmEntityBase
    {
        [Key]
        [DatabaseGenerated(DatabaseGenerationOption.Identity)]
        public int ContactId { get; set; }

        [Required(ErrorMessage = "Please enter the contact's first name")]
        [StringLength(50, ErrorMessage = "First name too long")]
        public string FirstName { get; set; }

        [StringLength(50, ErrorMessage = "Middle name too long")]
        public string MiddleName { get; set; }

        [Required(ErrorMessage = "Please enter the contact's last name")]
        [StringLength(50, ErrorMessage = "Last name too long")]
        public string LastName { get; set; }

        [StringLength(100, ErrorMessage = "Nick/preferred name too long")]
        public string NickName { get; set; }

        [StringLength(50, ErrorMessage = "Tax identifier number too long")]
        public string TaxIdNumber { get; set; }

        [StringLength(20, ErrorMessage = "Home phone too long")]
        public string HomePhone { get; set; }

        [StringLength(20, ErrorMessage = "Daytime phone too long")]
        public string DaytimePhone { get; set; }

        [StringLength(20, ErrorMessage = "Mobile phone too long")]
        public string MobilePhone { get; set; }

        [StringLength(100, ErrorMessage = "Primary email too long")]
        [RegularExpression(".+\\@.+\\..+", ErrorMessage = "Please enter a valid email address")]
        public string PrimaryEmail { get; set; }

        [StringLength(100, ErrorMessage = "Secondary email too long")]
        [RegularExpression(".+\\@.+\\..+", ErrorMessage = "Please enter a valid email address")]
        public string SecondaryEmail { get; set; }

        [Required(ErrorMessage = "Please select the contact's gender")]
        public bool IsFemale { get; set; }

        public bool Inactive { get; set; }

        public DateTime? DateOfBirth { get; set; }

        public virtual ICollection<Organization> Organizations { get; set; }

        public virtual ICollection<Address> Addresses { get; set; }

        public virtual ICollection<Donation> Donations { get; set; }

        public Contact()
        {
            Organizations = new HashSet<Organization>();
            Addresses = new HashSet<Address>();
            Donations = new HashSet<Donation>();
        }
    }
}
